package service

import (
	"errors"
	"im/model"
	"im/utils"
)

type ChatService struct{}

func (cs *ChatService) CheckToken(userid uint, token string) (bool, error) {
	var user model.User
	res := utils.DB.Where(map[string]interface{}{"id": userid}).First(&user)
	if res.Error != nil {
		return false, errors.New("chat-数据库查询token出错")
	}
	if user.ToKen != token {
		return false, errors.New("token不对")
	}
	return true, nil
}
